home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / FromTheMag / JW FLV MEDIA PLAYER 4.2 / mediaplayer.exe / player.swf / scripts / com / jeroenwijering / player / Player.as < prev    next >
Text File  |  2008-11-04  |  4KB  |  130 lines

  1. package com.jeroenwijering.player
  2. {
  3.    import com.jeroenwijering.events.PlayerEvent;
  4.    import com.jeroenwijering.events.SPLoaderEvent;
  5.    import com.jeroenwijering.plugins.Controlbar;
  6.    import com.jeroenwijering.plugins.Display;
  7.    import com.jeroenwijering.plugins.Playlist;
  8.    import com.jeroenwijering.plugins.Rightclick;
  9.    import com.jeroenwijering.utils.Configger;
  10.    import flash.display.MovieClip;
  11.    import flash.events.Event;
  12.    
  13.    public class Player extends MovieClip
  14.    {
  15.        
  16.       
  17.       protected var loader:SPLoader;
  18.       
  19.       protected var model:Model;
  20.       
  21.       public var config:Object;
  22.       
  23.       public var skin:MovieClip;
  24.       
  25.       public var view:View;
  26.       
  27.       protected var controller:Controller;
  28.       
  29.       protected var configger:Configger;
  30.       
  31.       public var player:MovieClip;
  32.       
  33.       public function Player()
  34.       {
  35.          config = {
  36.             "author":undefined,
  37.             "description":undefined,
  38.             "date":undefined,
  39.             "duration":0,
  40.             "file":undefined,
  41.             "image":undefined,
  42.             "link":undefined,
  43.             "start":0,
  44.             "tags":undefined,
  45.             "title":undefined,
  46.             "type":undefined,
  47.             "backcolor":undefined,
  48.             "frontcolor":undefined,
  49.             "lightcolor":undefined,
  50.             "screencolor":undefined,
  51.             "controlbar":"bottom",
  52.             "controlbarsize":20,
  53.             "height":300,
  54.             "playlist":"none",
  55.             "playlistsize":180,
  56.             "skin":undefined,
  57.             "width":400,
  58.             "autostart":false,
  59.             "bufferlength":1,
  60.             "displayclick":"play",
  61.             "icons":true,
  62.             "item":0,
  63.             "logo":undefined,
  64.             "mute":false,
  65.             "quality":true,
  66.             "repeat":"none",
  67.             "resizing":true,
  68.             "shuffle":false,
  69.             "state":"IDLE",
  70.             "stretching":"uniform",
  71.             "volume":90,
  72.             "abouttext":undefined,
  73.             "aboutlink":"http://www.jeroenwijering.com/?item=JW_FLV_Player",
  74.             "client":undefined,
  75.             "id":undefined,
  76.             "linktarget":"_blank",
  77.             "plugins":undefined,
  78.             "streamer":undefined,
  79.             "token":undefined,
  80.             "tracecall":undefined,
  81.             "version":"4.2.95"
  82.          };
  83.          super();
  84.          visible = false;
  85.          skin = this["player"];
  86.          addEventListener(Event.ADDED_TO_STAGE,loadConfig);
  87.       }
  88.       
  89.       protected function startPlayer(param1:SPLoaderEvent = null) : *
  90.       {
  91.          loader.removeEventListener(SPLoaderEvent.PLUGINS,startPlayer);
  92.          dispatchEvent(new PlayerEvent(PlayerEvent.READY));
  93.          visible = true;
  94.       }
  95.       
  96.       protected function loadMVC(param1:SPLoaderEvent = null) : void
  97.       {
  98.          controller = new Controller(config,skin);
  99.          model = new Model(config,skin,controller);
  100.          view = new View(config,skin,controller,model,loader);
  101.          controller.start(model,view);
  102.          loadPlugins();
  103.       }
  104.       
  105.       protected function loadSkin(param1:Event = null) : void
  106.       {
  107.          loader = new SPLoader(this);
  108.          loader.addEventListener(SPLoaderEvent.SKIN,loadMVC);
  109.          loader.loadSkin(config["skin"]);
  110.       }
  111.       
  112.       protected function loadConfig(param1:Event = null) : void
  113.       {
  114.          configger = new Configger(this);
  115.          configger.addEventListener(Event.COMPLETE,loadSkin);
  116.          configger.load(config);
  117.       }
  118.       
  119.       protected function loadPlugins() : void
  120.       {
  121.          new Rightclick().initializePlugin(view);
  122.          new Display().initializePlugin(view);
  123.          new Playlist().initializePlugin(view);
  124.          loader.addEventListener(SPLoaderEvent.PLUGINS,startPlayer);
  125.          loader.loadPlugins(config["plugins"]);
  126.          new Controlbar().initializePlugin(view);
  127.       }
  128.    }
  129. }
  130.